package com.yun.algorithmproblem.leetcode;

import java.util.Arrays;

public class Leetcode3136 {

    public boolean isValid(String word) {
        if (word.length() < 3) {
            return false;
        }
        word = word.toUpperCase();
        boolean vowel = false, consonant = false;
        int[] vowels = {65, 69, 73, 79, 85};
        for (int i = 0; i < word.length(); i++) {
            int c = word.charAt(i);
            if (c < 48 || (58 <= c && c < 65) || 91 <= c) {
                return false;
            } else if (c < 58) {
                continue;
            } else if (Arrays.binarySearch(vowels, c) >= 0) {
                vowel = true;
            } else {
                consonant = true;
            }
        }
        return vowel && consonant;
    }
}
